package com.jie.user.controller;

import com.jie.common.result.Result;
import com.jie.component.validation.annotion.Valid;
import com.jie.model.dto.user.UserLoginWithPhoneDTO;
import com.jie.model.vo.user.UserLoginWitPhoneVO;
import com.jie.user.service.UserLoginService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jie
 * @version 1.0 2025-02-13
 */
@RestController
@RequestMapping("/login")
@RequiredArgsConstructor
public class UserLoginController {

    private final UserLoginService userLoginService;

    /**
     * 手机号登录，返回登录的token
     * @return
     */
    @PostMapping("/phone")
    @Valid
    public Result<UserLoginWitPhoneVO> loginWithPhone(@Valid UserLoginWithPhoneDTO userLoginWithPhoneDTO) {
        UserLoginWitPhoneVO userLoginWitPhoneVO = userLoginService.loginWithPhone(userLoginWithPhoneDTO);
        return Result.success(userLoginWitPhoneVO);
    }

}
